package tree.leetcode_116_medium;

public class ConnectRecur {
    public Node connect(Node root){
        if(root == null){
            return null;
        }
        if(root.left != null) {
            root.left.next = root.right;
            root.right.next = root.next == null ? null : root.next.left;
        }
        connect(root.left);
        connect(root.right);
        return root;
    }
}
